package com.hua.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一的结果返回类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private  Integer code;
    private  String  message;
    private  Object  data;


    /**
     * 成功请求的返回类型
     * @param
     * @return
     */

    public static Result success(Object data){
        return new Result(20000,"success",data);
    } //数据自定义
    public static Result success(Object data, String message){
        return new Result(20000,message,data);
    }//消息、数据自定义
    public static Result success(String message){
        return new Result(20000,message,null);
    }//消息自定义

    /**
     * 失败请求的返回
     * @return
     */
    public static Result fail(){
        return new Result(20001,"fail",null);
    }//无参
    public static Result fail(String message){
        return new Result(20001,message,null);
    }//消息自定义
    public static Result fail(Object data,String message){
        return new Result(20001,message,data);
    }//消息自定义


    /**
     * 登录失效的返回
     */
    public static Result loginFailure(){
        return new Result(20002,"登录失效，请重新登录！",null);
    }

}
